* This file codes Study 4 data for Timothy J. Ryan, 
* "Actions Versus Consequences in Political Arguments: Insights 
* from Moral Psychology" (JOP). Analysis was conducted on 
* Stata/SE 14.2 for Mac (64-bit Intel).

clear all
insheet using "Study4_raw.csv", clear

foreach var in gcext1 gcext2 ssext1 ssext2 {
	replace `var' = (`var'-1)/8
	}
	
foreach iss in gc ss {
	gen `iss'extfold = sqrt(((`iss'ext1-.5) / .5)^2)
	replace `iss'imp = (`iss'imp - 1) / 4
	replace `iss'relev = (`iss'relev - 1) / 4
	gen `iss'mor = ((`iss'mc1 + `iss'mc2) - 2) / 8
	}

* Did R see deont or cons arguments?
gen ssdeont = .
gen gcdeont = .

replace gcdeont = 1 if gclibd1t1_1!=.
replace gcdeont = 1 if gccond1t1_1!=.
replace gcdeont = 0 if gclibc1t1_1!=.
replace gcdeont = 0 if gcconc1t1_1!=.

replace ssdeont = 1 if sslibd1t1_1!=.
replace ssdeont = 1 if sscond1t1_1!=.
replace ssdeont = 0 if sslibc1t1_1!=.
replace ssdeont = 0 if ssconc1t1_1!=.

gen gcconseq = 1-gcdeont
gen ssconseq = 1-ssdeont	
	
* Did R see liberal or conservative argument? (Determined for most people, but randomized for people with neutral issue opinion.)
gen sslibarg = .
gen ssconsarg = .
gen gclibarg = .
gen gcconsarg = .

replace sslibarg = 1 if sslibd1t1_1!=. | sslibc1t1_1!=.
replace sslibarg = 0 if sscond1t1_1!=. | ssconc1t1_1!=.
replace ssconsarg = 0 if sslibd1t1_1!=. | sslibc1t1_1!=.
replace ssconsarg = 1 if sscond1t1_1!=. | ssconc1t1_1!=.

replace gclibarg = 1 if gclibd1t1_1!=. | gclibc1t1_1!=.
replace gclibarg = 0 if gccond1t1_1!=. | gcconc1t1_1!=.
replace gcconsarg = 0 if gclibd1t1_1!=. | gclibc1t1_1!=.
replace gcconsarg = 1 if gccond1t1_1!=. | gcconc1t1_1!=.	
	
* Movement
gen gcmove = . // Conservatization
replace gcmove = gcext2 - gcext1
gen ssmove = .
replace ssmove = ssext2 - ssext1

gen gcmove3 = .
replace gcmove3 = gcmove if gcconsarg==1
replace gcmove3 = -1*gcmove if gclibarg==1
gen ssmove3 = .
replace ssmove3 = ssmove if ssconsarg==1
replace ssmove3 = -1*ssmove if sslibarg==1

* Demographics
egen agebin = cut(age), at(18,29,39,49,59,69,120) icodes

lab def educ 1 "Less than HS" 2 "Diploma" 3 "Some Col" 4 "BA" 5 "Adv. Degree"
lab val educ educ	
	
save "Study4_working_wide.dta", replace

keep caseid ///
	gcmove3 gcextfold gcimp gcrelev gcmor gcdeont ///
     ssmove3 ssextfold ssimp ssrelev ssmor ssdeont

foreach iss in gc ss {
	foreach dv in extfold imp relev mor deont move3 {
		rename `iss'`dv' `dv'`iss'
		}
	}

reshape long extfold mor imp relev deont move3, i(caseid) j(gc) string
encode gc, gen(issue)
drop gc
gen costsarg = 1-deont

save "Study4_working_long.dta", replace
